package com.example.sql_damo;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

public class cs extends AppCompatActivity {

    private DBhelpen dBhelpen;
    private SQLiteDatabase sqLiteDatabase;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.log);
        dBhelpen = new DBhelpen(this);
        inser("liu","123");
        update("liu","234");
    }

    private void update(String name, String s) {
        sqLiteDatabase=dBhelpen.getWritableDatabase();
        ContentValues contentValues=new ContentValues();
        contentValues.put("pas",s);
        int number=sqLiteDatabase.update("ta_table",contentValues,"name=?",new String[]{name});
        sqLiteDatabase.close();

    }

    private void inser(String name,String pas) {
        sqLiteDatabase = dBhelpen.getWritableDatabase();
        ContentValues contentValues=new ContentValues();
        contentValues.put("name",name);
        contentValues.put("password",pas);
        long tb_table = sqLiteDatabase.insert("tb_table", null, contentValues);
        sqLiteDatabase.close();
    }
}
